<?php /*Added by suwondo*/ ?>
<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"JS-6");
$currentPage = $_SERVER["PHP_SELF"];
mysql_select_db($database_con_gl, $con_gl);
$noref = $_REQUEST['noref'];
$nokontrak = $_REQUEST['nokontrak'];
?>
<script type="text/javascript" src="js/jquery-1.4.js"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<h1>Data List Kendaraan</h1>
<p>Kendaraan yang muncul hanya kendaraan yang berstatus Available</p>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
	<tr valign="top" bgcolor="#FFFFFF" class="hide">
        <td colspan="11" align="right" style="border-bottom:solid 1px #E2EAC1;border-right:solid 1px #E2EAC1;">
			<form id="search" name="search" method="post" action="">
			<!-- Edit by suwondo -->
			  Pencarian data : 
				<label>
					<input name="cr_txt" type="text" id="cr_txt" placeholder="Find by: tipe kendaraan" onclick="this.select(); $(this).autocomplete('components/rtrans/search.autocomplete.php?proc=kendaraan&noref=<?php echo $noref; ?>', { width: 330 });" size="45" maxlength="100" onkeyup="javascript: $(this).autocomplete('components/rtrans/search.autocomplete.php?proc=kendaraan&noref=<?php echo $noref; ?>', { width: 330 }); $(this).result(function(event, data, formatted){ idx = formatted.split(' - '); window.location.href='index.php?component=rtrans&task=list_kendaraan&noref=<?php echo $noref; ?>&open=window&cr_kel=ALL&cr_txt='+idx[1]; });" <?php echo $_REQUEST['cr_txt'];?> />
				</label>
				<label><input name="Search" type="submit" id="Search" value="Search" /></label>
			</form>
		<?php
		if(isset($_POST['Search'])) {
			echo "<script>window.location=\"index.php?component=rtrans&task=list_kendaraan&noref=$noref&open=window&cr_kel=ALL&cr_txt=".str_replace(" ","+",$_POST[cr_txt])."\";</script>";
		}
		?>		</td>
	</tr>
	<tr>
		<th width="163"><strong>No. Polisi</strong></th>
		<th width="235">Merk</th>
		<th width="769"><strong>Tipe Kendaraan &amp; Tahun </strong></th>
		<th width="110" align="center" class="hide"><strong>Aksi</strong></th>
	</tr>
	<?php
	$key = trim($_REQUEST['cr_txt']); 
	switch($_REQUEST['tipecust']){
		case 'R' :
			$query = mysql_query("SELECT a.nopolisi, d.merk, b.tipekendaraan, a.tahun, a.tersedia, c.kendaraan from gl_masterkendaraan a, gl_tipekendaraan b, gl_retailtrans c, gl_merkkendaraan d where c.kendaraan=a.nopolisi AND a.tipekendaraan = b.id AND a.tersedia='1' AND c.no_ref = '$noref' AND  d.id=a.merk order by b.tipekendaraan, a.nopolisi asc") or die (mysql_error());
			while(list($nopolisi, $merk, $tipekendaraan, $tahun, $tersedia, $kendaraan) = mysql_fetch_row($query)){
				echo "<tr>";
				echo "<td>$nopolisi</td><td>$merk</td><td>$tipekendaraan - $tahun</td><td align='center'><input type='button' value='pilih' onclick=\"javascript: window.opener.document.getElementById('kendaraan').value='$nopolisi'; window.opener.document.getElementById('txtkendaraan').value='$tipekendaraan ($nopolisi)'; window.close(1000);\" /></td>";
				echo "</tr>";
			}
			break;
		case 'C' :
			$query = mysql_query("SELECT a.nopolisi, d.merk, b.tipekendaraan, a.tahun, a.tersedia, c.kendaraan from gl_masterkendaraan a, gl_tipekendaraan b, gl_dkontrak c, gl_merkkendaraan d where c.kendaraan=a.nopolisi AND a.tipekendaraan = b.id AND d.id=a.merk AND a.tersedia='1' and c.kontrak = '$nokontrak' order by b.tipekendaraan, a.nopolisi asc") or die (mysql_error());
			while(list($nopolisi, $merk, $tipekendaraan, $tahun, $tersedia, $kendaraan) = mysql_fetch_row($query)){
				echo "<tr>";
				echo "<td>$nopolisi</td><td>$merk</td><td>$tipekendaraan - $tahun</td><td align='center'><input type='button' value='pilih' onclick=\"javascript: window.opener.document.getElementById('kendaraan').value='$nopolisi'; window.opener.document.getElementById('txtkendaraan').value='$tipekendaraan ($nopolisi)'; window.close(1000);\" /></td>";
				echo "</tr>";
			}
			break;
	}
	?>
 </table>
